-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Search] Set keep_alive parameter in async search #73712
Conversation
Pinging @elastic/kibana-app-arch (Team:AppArch) |
x-pack/plugins/data_enhanced/server/search/es_search_strategy.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one unrelated comment but the change LGTM.
Note that the keep alive is not checked aggressively so setting it to 1m
doesn't mean that the query will be cancelled right away but that's a good workaround if we cannot cancel explicitly in Kibana.
@@ -81,7 +81,7 @@ async function asyncSearch( | |||
const path = encodeURI(request.id ? `/_async_search/${request.id}` : `/${index}/_async_search`); | |||
|
|||
// Wait up to 1s for the response to return | |||
const query = toSnakeCase({ waitForCompletionTimeout: '100ms', ...queryParams }); | |||
const query = toSnakeCase({ waitForCompletionTimeout: '100ms', keepAlive: '1m', ...queryParams }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated but it would be good to set the batched_reduce_size
to a value greater than the default (5
). I am saying this because we don't use partial results in Kibana at the moment so we don't need to create a partial results every 5 shards. Something like 32 or 64 should make the query faster and we can restore the default value when partial results are handled in Kibana ? It's also outside of the scope of this PR so I can open a new one if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any risks associated with increasing this value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, in blocking search the value is set to 512
so I think it's the other way around, 5
is too low and can have a negative impact on queries in terms of memory and speed. The only advantage to set a low value is for partial results so we should set it higher until we expose partial results in Kibana.
@elasticmachine merge upstream |
💚 Build SucceededBuild metrics
History
To update your PR or re-run it, just comment with: |
* [Search] Set keep_alive parameter in async search * Revert accidental change * Add batched_reduce_size Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* [Search] Set keep_alive parameter in async search * Revert accidental change * Add batched_reduce_size Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* [Search] Set keep_alive parameter in async search * Revert accidental change * Add batched_reduce_size Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
) * [Search] Set keep_alive parameter in async search (#73712) * [Search] Set keep_alive parameter in async search * Revert accidental change * Add batched_reduce_size Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> * Fix test Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Summary
Fixes #73443.
There are a few scenarios where we would want to automatically cancel
_async_search
requests:Prior to this PR, we were properly handling the first two cases, but not the last two. This PR updates our usage of
_async_search
to include thekeep_alive
property, which is set to1m
. From the documentation:We send this parameter in each request to
_async_search
, which will extend the request by one minute (from the time of the request). If the browser is closed or the user navigates away from Kibana, the requests will no longer be sent, and after one minute, the task in Elasticsearch will be cancelled.Checklist
Release notes
Kibana now sets the
keep_alive
parameter to1m
in_async_search
requests to Elasticsearch to ensure that search requests are cancelled if a user closes the browser or navigates outside of Kibana before a request completes.